package com.gitee.wsl.ext.collection


inline fun <T, R> Iterable<T>.flatMapTranArray(transform: (T) -> Array<R>): List<R> {
    return flatMapTranArrayTo(ArrayList<R>(), transform)
}

inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTranArrayTo(destination: C, transform: (T) -> Array<R>): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }

    return destination
}